# Copyright 2022-2023 The Khronos Group Inc.
# SPDX-License-Identifier: Apache-2.0

# Configure Vulkan Guide Antora tree with transformed markup files.
# Branch selection may come later. For now it is the current branch.

RMRF = rm -rf
CP = cp

# Antora ROOT module directory where files are copied
ROOT = antora/modules/ROOT

setup: setup_spec

# Rewrite spec sources and images into module directory
# ROOT component - Vulkan spec
# Page headers are added to pull in required attributes
# Also creates pageMap.cjs for use by the Antora version of the spec macros
setup_spec:
	mkdir -p $(ROOT)/pages
	$(CP) $(wildcard chapters/[A-Za-z]*.adoc) $(ROOT)/pages/
	mkdir -p $(ROOT)/pages/extensions
	$(CP) $(wildcard chapters/extensions/[A-Za-z]*.adoc) $(ROOT)/pages/extensions/
	mkdir -p $(ROOT)/images
	$(CP) $(wildcard chapters/images/[A-Za-z]*.png) $(ROOT)/images/
	$(CP) $(wildcard images/[A-Za-z]*.png) $(ROOT)/images/
	mkdir -p $(ROOT)/images/extensions
	$(CP) $(wildcard chapters/images/extensions/[A-Za-z]*.png) $(ROOT)/images/extensions

# Files generated by 'setup' target
ANTORA_GENERATED = \
	$(filter-out $(ROOT)/pages/index.adoc,$(wildcard $(ROOT)/pages/*.adoc)) \
	$(ROOT)/pages/extensions \
	$(ROOT)/images

clean:
	$(RMRF) $(ANTORA_GENERATED)
